package com.lagou.rpc.consumer.controller;

import com.lagou.rpc.api.IUserService;
import com.lagou.rpc.consumer.service.ProxyService;
import com.lagou.rpc.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("rpc")
public class RpcController {

    @Autowired
    ProxyService proxyService;

    @RequestMapping("/index/{id}")
    public String index(@PathVariable("id") Integer id, Model model) throws InterruptedException {
        long currentTimeMillisf = System.currentTimeMillis();
        IUserService userService = proxyService.getIUserService();
        User user = userService.getById(id);
        model.addAttribute("user", user);

//        long currentTimeMillisl = System.currentTimeMillis();
//        long seconds = TimeUnit.MILLISECONDS.toSeconds(currentTimeMillisl - currentTimeMillisf);
//        user.setSecond(seconds);

//        String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
//        user.setDate(date);
        return "myThymeleaf";
    }

}
